package com.core.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.common.ibatis.BaseDao;
import com.common.page.Pagination;
import com.core.entity.ActivityType;
import com.core.entity.ActivityTypeExample;

@Repository
public class ActivityTypeDAOImpl extends BaseDao implements ActivityTypeDAO {

	public ActivityTypeDAOImpl() {
		super();
	}

	public void insert(ActivityType record) {
		getSqlMapClientTemplate().insert(
				"activity_type.abatorgenerated_insert", record);
	}

	public int updateByPrimaryKey(ActivityType record) {
		int rows = getSqlMapClientTemplate().update(
				"activity_type.abatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	public int updateByPrimaryKeySelective(ActivityType record) {
		int rows = getSqlMapClientTemplate().update(
				"activity_type.abatorgenerated_updateByPrimaryKeySelective",
				record);
		return rows;
	}

	public List selectByExample(ActivityTypeExample example) {
		List list = getSqlMapClientTemplate().queryForList(
				"activity_type.abatorgenerated_selectByExample", example);
		return list;
	}

	public ActivityType selectByPrimaryKey(Integer id) {
		ActivityType key = new ActivityType();
		key.setId(id);
		ActivityType record = (ActivityType) getSqlMapClientTemplate()
				.queryForObject(
						"activity_type.abatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	public int deleteByExample(ActivityTypeExample example) {
		int rows = getSqlMapClientTemplate().delete(
				"activity_type.abatorgenerated_deleteByExample", example);
		return rows;
	}

	public int deleteByPrimaryKey(Integer id) {
		ActivityType key = new ActivityType();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete(
				"activity_type.abatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	public int countByExample(ActivityTypeExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"activity_type.abatorgenerated_countByExample", example);
		return count.intValue();
	}

	public int updateByExampleSelective(ActivityType record,
			ActivityTypeExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate()
				.update(
						"activity_type.abatorgenerated_updateByExampleSelective",
						parms);
		return rows;
	}

	public int updateByExample(ActivityType record, ActivityTypeExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"activity_type.abatorgenerated_updateByExample", parms);
		return rows;
	}

	private static class UpdateByExampleParms extends ActivityTypeExample {
		private Object record;

		public UpdateByExampleParms(Object record, ActivityTypeExample example) {
			super(example);
			this.record = record;
		}

		public Object getRecord() {
			return record;
		}
	}

	@Override
	public Pagination getPage(Pagination page, ActivityTypeExample example) {
		return super.selectByPage(page, example,
				"activity_type.abatorgenerated_selectByExamplePage",
				"activity_type.abatorgenerated_countByExample");
	}
}